﻿using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ToolsAndHjt212Parser
{
    public class FlagTranslation
    {
        private static readonly ILog Log = LogManager.GetLogger(typeof(FlagTranslation));
        public static string GetDataFlagMean(string flag)
        {
            switch (flag)
            {
                case "N":
                    return "N:在线监控（监测）仪器仪表工作正常";
                case "F":
                    return "F:在线监控（监测）仪器仪表停运";
                case "M":
                    return "M:在线监控（监测）仪器仪表处于维护期间产生的数据";
                case "S":
                    return "S:手工输入的设定值";
                case "D":
                    return "D:在线监控（监测）仪器仪表故障";
                case "C":
                    return "C:在线监控（监测）仪器仪表处于校准状态";
                case "T":
                    return "T:在线监控（监测）仪器仪表采样数值超过测量上限";
                case "B":
                    return "B:在线监控（监测）仪器仪表与数采仪通讯异常";

            }
            Log.Warn(string.Format("The Flag '{0}' is invalid!", flag));
            return null;
        }


        public static string GetQnRtnMean(string qnRtn)
        {
            switch (qnRtn)
            {
                case "1":
                    return "1:准备执行请求/现场机已接收";
                case "2":
                    return "2:请求被拒绝";
                case "3":
                    return "3:PW错误";
                case "4":
                    return "4:MN错误";
                case "5":
                    return "5:ST错误";
                case "6":
                    return "6:Flag错误";
                case "7":
                    return "7:QN错误";
                case "8":
                    return "8:CN错误";
                case "9":
                    return "9:CRC校验错误";
                case "100":
                    return "100:未知错误";

            }
            Log.Warn(string.Format("The QnRtn '{0}' is invalid!", qnRtn));
            return null;
        }

        public static string GetExeRtnMean(string exeRtn)
        {
            switch (exeRtn)
            {
                case "1":
                    return "1:执行成功";
                case "2":
                    return "2:执行失败,但不知道原因";
                case "3":
                    return "3:命令请求条件错误/无阀信号";
                case "4":
                    return "4:正在执行/通讯超时";
                case "5":
                    return "5:系统繁忙不能执行";
                case "6":
                    return "6:系统故障";
              
                case "100":
                    return "100:没有数据";

            }
            Log.Warn(string.Format("The ExeRtn '{0}' is invalid!", exeRtn));
            return null;
        }
       
    }
}
